<?php
// 批量测试菜品信息获取API

// 模拟API请求
function testBatchDishInfoAPI() {
    $url = 'http://localhost/api/food_ingredient/batchGetDishInfo';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/x-www-form-urlencoded',
    ]);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return $response;
}

// 测试批量获取菜品信息
$result = testBatchDishInfoAPI();
echo "API Response:\n";
echo $result . "\n";

// 解析JSON响应
$responseData = json_decode($result, true);
if ($responseData && $responseData['code'] == 1) {
    echo "\n处理结果:\n";
    echo "成功处理菜品数量: " . ($responseData['data']['success_count'] ?? 0) . "\n";
    echo "处理的菜品ID: " . implode(', ', $responseData['data']['processed_dishes'] ?? []) . "\n";
} else {
    echo "\nAPI调用失败: " . ($responseData['msg'] ?? '未知错误') . "\n";
}
?>